<!DOCTYPE html>
<html lang='zh-CN'>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        .tangram-suggestion-main {z-index: 99999999999;}
        body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";font-size:14px;}
        #l-map{height:600px;width:80%;}
        #r-result{width:100%;}
    </style>

    <title>签到机制管理</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.min.css" rel="stylesheet">
    <link href="js/select2/select2.min.css" rel="stylesheet">
    <!--修改图片-->
    <link rel="stylesheet" href="js/dropzone/min/basic.min.css" />
    <link rel="stylesheet" href="js/dropzone/min/dropzone.min.css" />


</head>
<body>
<div class="container-fluid p-t-15">

    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header"><h4>签到机制</h4></div>
                <div class="card-body">
                    <ul id="myTabs" class="nav nav-tabs" role="tablist">
                        <li class="active"><a href="#home" id="home-tab" role="tab" data-toggle="tab" onclick="dji('pro_data')">规则管理</a></li>
<!--                        <li><a href="#profile" role="tab" id="profile-tab" data-toggle="tab" onclick="dji('tb_roles')">记录管理</a></li>-->
                    </ul>
                    <div id="myTabContent" class="tab-content">
                        <div class="tab-pane fade active in" id="home">
                            <form class="form-inline" method="post" id="searchForm">
                                <div class="form-group">
                                    <button class="btn btn-warning btn_query btn-round" type="button" id="editBtn">编辑</button>
                                </div>
                            </form>
                            <table id="pro_data"></table>
                        </div>
                        <div class="tab-pane fade" id="profile">
                            <form class="form-inline" method="post" id="searchForm2">
                                <div class="form-group">
                                    <label>会员ID:</label>
                                    <input type="text" class="form-control" name="memberId">
                                </div>
                                <div class="form-group">
                                    <button class="btn btn-info btn_query btn-round" type="button" id="searchFormBtn2" >查询</button>
                                </div>
                            </form>
                            <table id="pro_data2"></table>
                        </div>
                    </div>

                </div>
            </div>
        </div>


    </div>

    <!--  添加与编辑模态框 -->
    <div class="modal fade" id="addOrEditModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog modal-lg" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">签到规则管理</h4>
                </div>

                <div class="modal-body">
                    <form id="addOrEditForm" method="post">
                        <div class="form-group">
                            <label for="couponAmount" class="control-label">领取金券金额：</label>
                            <input type="hidden" name="id">
                            <input type="text" class="form-control" id="couponAmount" name="couponAmount">
                        </div>
                        <div class="form-group col-md-12">
                            <label for="dayOne" class="control-label">连续签到日期一：</label>
                            <input type="text" class="form-control" id="dayOne" name="dayOne" placeholder="设置日期"
                                   oninput="value=value.replace(/[^\d]/g,'')">
                            <div class="form-group col-md-4">
                                <label for="dayOneType"></label>
                                <select class="form-control" name="dayOneType" id="dayOneType">
                                    <option value="">请选择类型</option>
                                    <option value="1">金券</option>
                                    <option value="2">积分</option>
                                    <option value="3">商品</option>
                                </select>
                            </div>
                            <div class="form-group col-md-6" id="dayOneInput">
                                <label for="dayOnejinjuan"></label>
                                <input type="text" class="form-control" id="dayOnejinjuan" name="dayOnejinjuan"
                                       placeholder="设置金券" oninput="value=value.replace(/[^\d]/g,'')">
                                <label for="dayOnejifen"></label>
                                <input type="text" class="form-control" id="dayOnejifen" name="dayOnejifen"
                                       placeholder="设置积分" oninput="value=value.replace(/[^\d]/g,'')">
                            </div>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="dayTwo" class="control-label">连续签到日期二：</label>
                            <input type="text" class="form-control" id="dayTwo" name="dayTwo" placeholder="设置日期"
                                   oninput="value=value.replace(/[^\d]/g,'')">
                            <div class="form-group col-md-4">
                                <label for="dayTwoType"></label>
                                <select class="form-control" name="dayTwoType" id="dayTwoType">
                                    <option value="">请选择类型</option>
                                    <option value="1">金券</option>
                                    <option value="2">积分</option>
                                    <option value="3">商品</option>
                                </select>
                            </div>
                            <div class="form-group col-md-6" id="dayTwoInput">
                                <label for="dayTwojinjuan"></label>
                                <input type="text" class="form-control" id="dayTwojinjuan" name="dayTwojinjuan"
                                       placeholder="设置金券" oninput="value=value.replace(/[^\d]/g,'')">
                                <label for="dayTwojifen"></label>
                                <input type="text" class="form-control" id="dayTwojifen" name="dayTwojifen"
                                       placeholder="设置积分" oninput="value=value.replace(/[^\d]/g,'')">
                            </div>
                        </div>
                        <div class="form-group col-md-12">
                            <label for="dayThree" class="control-label">连续签到日期三：</label>
                            <input type="text" class="form-control" id="dayThree" name="dayThree" placeholder="设置日期"
                                   oninput="value=value.replace(/[^\d]/g,'')">
                            <div class="form-group col-md-4">
                                <label for="dayThreeType"></label>
                                <select class="form-control" name="dayThreeType" id="dayThreeType">
                                    <option value="">请选择类型</option>
                                    <option value="1">金券</option>
                                    <option value="2">积分</option>
                                    <option value="3">商品</option>
                                </select>
                            </div>
                            <div class="form-group col-md-6" id="dayThreeInput">
                                <label for="dayThreejinjuan"></label>
                                <input type="text" class="form-control" id="dayThreejinjuan" name="dayThreejinjuan"
                                       placeholder="设置金券" oninput="value=value.replace(/[^\d]/g,'')">
                                <label for="dayThreejifen"></label>
                                <input type="text" class="form-control" id="dayThreejifen" name="dayThreejifen"
                                       placeholder="设置积分" oninput="value=value.replace(/[^\d]/g,'')">
                            </div>
                        </div>
                    </form>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" id="saveFormBtn" class="btn btn-primary">保存</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>






<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/bootstrap-table/bootstrap-table.js"></script>
<script type="text/javascript" src="js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript" src="js/zero2one/zero2one.version.js"></script>
<script type="text/javascript" src="js/zero2one/zero2one.core.js"></script>
<script type="text/javascript" src="js/dropzone/min/dropzone.min.js"></script>
<script type="text/javascript" src="js/bootstrapvalidator/dist/js/bootstrapValidator.js"></script>
<!-- Jcrop截图插件 -->
<script type="text/javascript" src="js/jcrop/jquery.Jcrop.js"></script>
<script type="text/javascript" src="js/jcrop/out.js"></script>
<!-- bootstrap表单验证插件 -->
<script type="text/javascript" src="js/bootstrap-validator-master/dist/validator.js"></script>
<!-- ckeditor富文本插件 -->
<script src="js/ckeditor/ckeditor.js"></script>
<!-- select2下拉框插件 -->
<script src="js/select2/select2.min.js"></script>
<script src="js/select2/i18n/zh-CN.js"></script>
<!-- jquery-form表单提交插件 -->
<script type="text/javascript" src="js/jquery-form/jquery.form.js"></script>
<!-- bootstrap弹出框插件 -->
<script type="text/javascript" src="js/jquery.bootstrap.min.js"></script>
<!-- 表单填充插件 -->
<script type="text/javascript" src="js/jquery-form/jquery.formloader.js"></script>
<!-- boostrap-combox下拉框检索插件 -->
<script type="text/javascript" src="js/suggest/bootstrap-suggest.min.js"></script>
<script type="text/javascript" src="js/zero2one/zero2one.suggest.js"></script>
<script type="text/javascript">

        //设置表头
        var columns = [
            {checkbox: true},
            {field: 'id',title: 'ID',visible:false},
            {field: 'couponAmount',title: '奖励金券金额'},
            {field: 'operatorName',title: '操作人'},
            {field: 'operatorTime',title: '操作时间',formatter: function (value) {
                    return zero2one.dateFormat(value, 'Y-m-d H:i:s')}}
        ];

        var columns2 = [
            {checkbox: true},
            {field: 'id',title: 'ID',visible:false},
            {field: 'memberId',title: '会员ID'},
            {field: 'memberName',title: '会员名字'},
            {field: 'couponAmount',title: '领取金券金额'},
            {field: 'operatorTime',title: '操作时间',formatter: function (value) {
                    return zero2one.dateFormat(value, 'Y-m-d H:i:s')}}
        ];
        //进入主界面加载数据
        zero2one.datagrid("pro_data", "/remote/coupon/queryRule",function (params) {
            return $.extend(zero2one.tableInitParam(params), zero2one.form2json("searchForm"));
        }, columns);

        zero2one.datagrid("pro_data2", "/remote/coupon/queryRecord",function (params) {
            return $.extend(zero2one.tableInitParam(params), zero2one.form2json("searchForm2"));
        }, columns2);


        $("#searchFormBtn2").click(function () {
            $('#pro_data2').bootstrapTable('refresh');
        });

        //改变用户状态
        function changeUserStatus(proState) {
            //获取选中行的数据
            var datas = $('#pro_data').bootstrapTable('getSelections');
            //判断是否选中行数据，如果没有则提示
            if(datas.length > 0){
                $.messager.confirm("温馨提示", "您确定要改变状态吗?", function () {
                    zero2one.request("/change?f="+new Date().getTime(),{"proState" : proState,"ids" : zero2one.array2str(datas)},function (data) {
                        window.location.reload();
                    });
                })
            }else{
                $.messager.alert("温馨提示", "请至少选择一条数据操作");

            }
        }

        //点击编辑按钮弹出模态框
        $("#editBtn").click(function () {
            //获取选中行的数据
            var datas = $('#pro_data').bootstrapTable('getSelections');
            //判断是否选中行数据，如果没有则提示
            if(datas.length == 1){
                $("#dayOnejinjuan").hide();
                $("#dayOnejifen").hide();
                $("#dayTwojinjuan").hide();
                $("#dayTwojifen").hide();
                $("#dayThreejinjuan").hide();
                $("#dayThreejifen").hide();
                if (datas[0].dayOneType==1){
                    var num =datas[0].dayOneNum;
                    $("#dayOnejinjuan").show();
                    $("#dayOnejinjuan").attr("value",datas[0].dayOneNum);
                    $("#dayOnejinjuan").attr("placeholder",datas[0].dayOneNum)
                }else if (datas[0].dayOneType==2){
                    $("#dayOnejifen").show();
                    $("#dayOnejifen").attr("value",datas[0].dayOneNum);
                    $("#dayOnejifen").attr("placeholder",datas[0].dayOneNum)
                }
                if (datas[0].dayTwoType==1){
                    $("#dayTwojinjuan").show();
                    $("#dayTwojinjuan").attr("value",datas[0].dayTwoNum);
                    $("#dayTwojinjuan").attr("placeholder",datas[0].dayTwoNum)
                }else if (datas[0].dayTwoType==2){
                    $("#dayTwojifen").show();
                    $("#dayTwojifen").attr("value",datas[0].dayTwoNum);
                    $("#dayTwojifen").attr("placeholder",datas[0].dayTwoNum)
                }
                if (datas[0].dayThreeType==1){
                    $("#dayThreejinjuan").show();
                    $("#dayThreejinjuan").attr("value",datas[0].dayThreeNum);
                    $("#dayThreejinjuan").attr("placeholder",datas[0].dayThreeNum)
                }else if (datas[0].dayThreeType==2){
                    $("#dayThreejifen").show();
                    $("#dayThreejifen").attr("value",datas[0].dayThreeNum);
                    $("#dayThreejifen").attr("placeholder",datas[0].dayThreeNum)

                }
                //填充表单
                $("#addOrEditForm").formloader({data: datas[0]});
            }else{
                $.messager.alert("温馨提示", "请选择一条数据操作");
                return;
            }
            $("#addOrEditModal").modal("show");
        });


        $('#addOrEditForm').bootstrapValidator({
            fields: {
                ruleName: {validators: {notEmpty: {message: '规则名称不能为空'}}},
            }
        });

        //清除选中行
        function dji(tableId) {
            $('#'+tableId).bootstrapTable("uncheckAll");
        }


        $("#saveFormBtn").click(function () {
            var bv = $('#addOrEditForm').data('bootstrapValidator');
            bv.validate();
            if (bv.isValid()) {
                zero2one.request("/remote/coupon/editRule?f="+new Date().getTime(),$("#addOrEditForm").serialize(),function (data) {
                    window.location.reload();

                });
            }
        });

        $("#dayOneType").change(function () {
            var v = $(this).val();
            if (v==1){
                $("#dayOnejinjuan").show();
                $("#dayOnejifen").hide()
            }else if (v==2){
                $("#dayOnejinjuan").hide();
                $("#dayOnejifen").show()
            }else if (v==3){
                $("#dayOnejinjuan").hide();
                $("#dayOnejifen").hide()
            }else if (v==0){
                $("#dayOnejinjuan").hide();
                $("#dayOnejifen").hide()
            }
        });

        $("#dayTwoType").change(function () {
            var v = $(this).val();
            if (v==1){
                $("#dayTwojinjuan").show();
                $("#dayTwojifen").hide()
            }
            else if (v==2){
                $("#dayTwojifen").show();
                $("#dayTwojinjuan").hide()
            }else if (v==3){
                $("#dayTwojifen").hide();
                $("#dayTwojinjuan").hide()
            }else if (v==0){
                $("#dayTwojifen").hide();
                $("#dayTwojinjuan").hide()
            }
        });

        $("#dayThreeType").change(function () {
            var v = $(this).val();
            if (v==1){
                $("#dayThreejinjuan").show();
                // $("#dayThreejinjuan").attr("required","required")
                $("#dayThreejifen").hide()
                // $("#dayThreejifen").removeAttr("required")
            }else if (v==2){
                $("#dayThreejifen").show();
                $("#dayThreejinjuan").hide()
            }else if (v==3){
                $("#dayThreejifen").hide();
                $("#dayThreejinjuan").hide()
            }else if (v==0){
                $("#dayThreejinjuan").hide();
                $("#dayThreejifen").hide()
            }
        })
    </script>

<script type="text/javascript">

</script>
</body>
</html>
